var express = require('express');
var path = require('path');
var http = require('http');
var routes = require('./routes');




var app = express();

app.set('view engine', 'ejs');
app.set('views', './tpl');

app.use('/', routes);



// catch 404 and forward to error handler
app.use(function(err, req, res, next) {
    err.status = 200;
    console.error(err);
    res.send('<pre>'+ err.toString()+'</pre>');
});






app.set('port', process.env['ENV_PORT'] || 10086);
app.set('address', '0.0.0.0');



http.createServer(app).
    listen(app.get('port'),app.get('host'),function(){
      console.log('listening at  %s:%d', app.get('address'), app.get('port'));
});
